package com.jifeng.api.crud.controller;

import com.jifeng.api.crud.entity.FeeLogEntity;
import com.jifeng.api.crud.service.FeeLogService;
import com.jifeng.api.utils.PageUtils;
import com.jifeng.api.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-09-29 19:33:23
 */
@RestController
@RequestMapping("crud/feelog")
public class FeeLogController {
    @Autowired
    private FeeLogService feeLogService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = feeLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		FeeLogEntity feeLog = feeLogService.getById(id);

        return R.ok().put("feeLog", feeLog);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody FeeLogEntity feeLog){
		feeLogService.save(feeLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody FeeLogEntity feeLog){
		feeLogService.updateById(feeLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		feeLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
